package com.sskj.mine.asset;

import android.support.v4.app.Fragment;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.flyco.tablayout.SlidingTabLayout;
import com.sskj.common.base.App;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.lib.util.ViewPagerBoolean;
import com.sskj.mine.R;
import com.sskj.mine.R2;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * @author Hey
 * Create at  2019/05/04
 */
@Route(path = RConfig.MINE_ASSET_RECORDS)
public class AssetRecordsActivity extends BaseActivity<AssetRecordsPresenter> {
    @BindView(R2.id.slidingTabLayout)
    SlidingTabLayout slidingTabLayout;
    @BindView(R2.id.viewPager)
    ViewPagerBoolean viewPager;
    @Autowired
    boolean isTWD = false;
    @Autowired
    String code;
    private String[] titles = new String[]{App.INSTANCE.getString(R.string.mineassetRecordsActivity1), App.INSTANCE.getString(R.string.mineassetRecordsActivity2), App.INSTANCE.getString(R.string.mineassetRecordsActivity3)};

    @Override
    public int getLayoutId() {
        return R.layout.mine_activity_asset_records;
    }

    @Override
    public AssetRecordsPresenter getPresenter() {
        return new AssetRecordsPresenter();
    }

    @Override
    public void initView() {
        ARouter.getInstance().inject(this);
        if (isTWD) {
            viewPager.setCurrentItem(2);
            slidingTabLayout.setVisibility(View.GONE);
        } else {
            setTitle(App.INSTANCE.getString(R.string.mineassetRecordsActivity4));
        }
        viewPager.setCanScrollble(false);
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.MINE_FRAGMENT_ASSET).withInt(Constans.TYPE, 1).withString("code", code).navigation());
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.MINE_FRAGMENT_ASSET).withInt(Constans.TYPE, 2).withString("code", code).navigation());
        fragments.add((Fragment) ARouter.getInstance().build(RConfig.MINE_FRAGMENT_OTHER_ASSET).withString("code", code).navigation());
        slidingTabLayout.setViewPager(viewPager, titles, this, fragments);
//        viewPager.addHeight(0,);
    }
}
